/*
 * 文件名：ConsumableDaoImpl.java
 * 版权：Copyright by www.wootide.com
 * 描述：
 * 修改人：wuliquan
 * 修改时间：2013-2-25
 * 跟踪单号：
 * 修改单号：
 * 修改内容：
 */
package com.wootide.cms.service.consumables.consumablesInfo.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.wootide.cms.common.QueryResults;
import com.wootide.cms.log.syslog.RunLog;
import com.wootide.cms.service.consumables.consumablesInfo.pojo.ConsumablesInfo;
import com.wootide.cms.service.consumables.consumablesInfo.dao.ConsumablesInfoDao;
/**
 * 易耗品数据访问层接口实现
 * 〈功能详细描述〉
 * @author wuliquan
 * @version 2013-2-25
 * @see ConsumablesInfoDaoImpl
 * @since
 */
public class ConsumablesInfoDaoImpl extends HibernateDaoSupport implements ConsumablesInfoDao
{
    /**
     * 运行日志
     */
    private RunLog runLog;
    
    public int findNumByConsumablesInfoName(String consumablesName)
    {
        runLog.debug("consumablesName=" + consumablesName);
        
        return ((Number)getHibernateTemplate().findByNamedQuery("findConsumablesInfoNumByName",
                consumablesName)
                .get(0)).intValue();
    }
    
    public ConsumablesInfo findOneConsumablesInfoByConsumableId(Integer consumablesId)
    {
        runLog.debug("consumablesId=" + consumablesId);
        
        return getHibernateTemplate().get(ConsumablesInfo.class, consumablesId);
    }
    
    @SuppressWarnings("unchecked")
    public ConsumablesInfo findOneConsumablesInfoByName(String consumableName)
    {
        runLog.debug("consumableName=" + consumableName);
        List<ConsumablesInfo> list = getHibernateTemplate().findByNamedQuery("findOneConsumablesInfoByName",consumableName);
        
        return list.isEmpty() ? null : (ConsumablesInfo)list.get(0);
    }

    public QueryResults findAllConsumablesInfos()
    {
        QueryResults queryResults = new QueryResults();
        
        queryResults.setResults(getHibernateTemplate().findByNamedQuery("findConsumablesInfos"));
        
        return queryResults;
    }
    
    public QueryResults findConsumablesInfosById(Integer consumablesInfoId)
    {
        return null;
    }

    public void setRunLog(RunLog runLog)
    {
        this.runLog = runLog;
    }
    
}
